package net.mukia.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity
@Table(name="R_GROUP")
public class Group  extends BaseBean{

	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private long id;
	
	@Column
	private String name;
	
	@Column
	private String memo;
	
	@OneToOne
	@JoinColumn(name="ACCOUNT_ID")
	private Account account;
	
	@ManyToMany(cascade={CascadeType.PERSIST,CascadeType.MERGE},fetch=FetchType.EAGER)
	@JoinTable(name="R_GROUP_ACCOUNT",joinColumns={ @JoinColumn(name="GROUP_ID")},inverseJoinColumns={@JoinColumn(name="ACCOUNT_ID")})
	private List<Account> accountList = new ArrayList<Account>(); 
	
	@ManyToMany
	@JoinTable(name="R_GROUP_ROLE_GRUOP"
	,joinColumns={ @JoinColumn(name="GROUP_ROLE_ID")}
	,inverseJoinColumns={@JoinColumn(name="GROUP_ID")})
	private List<GroupRole> groupRoleList;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getMemo() {
		return memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}

	public List<Account> getAccountList() {
		return accountList;
	}

	public void setAccountList(List<Account> accountList) {
		this.accountList = accountList;
	}

	public List<GroupRole> getGroupRoleList() {
		return groupRoleList;
	}

	public void setGroupRoleList(List<GroupRole> groupRoleList) {
		this.groupRoleList = groupRoleList;
	}

	public Account getAccount() {
		return account;
	}

	public void setAccount(Account account) {
		this.account = account;
	}
	
	
	
}
